//
//  I_Coach.m
//  YunDongAdmin
//
//  Created by lqq on 2018/9/7.
//  Copyright © 2018年 cloudfighting.com. All rights reserved.
//

#import "I_Coach.h"

@implementation I_Coach
/**
 根据教练编码查询教练账户
 */
+ (NetworkTask *)requestCoachAccountByCoachCode:(NSString *)coachCode
                                        success:(void(^)(M_Coach *coach))successBlock
                                        failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-coach-api/admin/2.0.0/getCoachAccountByCode" parameters:@{@"coachCode":SAFE_NIL_STRING(coachCode)} criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        if (successBlock) {
            M_Coach *coach = [[M_Coach alloc] initWithDictionary:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
            successBlock(coach);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}

/**
 邀请教练加入门店
 */
+ (NetworkTask *)inviteCoachWithCoachId:(NSString *)coachId
                                success:(void(^)(void))successBlock
                                failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-coach-api/admin/2.0.0/inviteCoach" parameters:@{@"coachId":SAFE_NIL_STRING(coachId)} criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        if (successBlock) {
            successBlock();
        }
        
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}

/**
 删除教练
 */
+ (NetworkTask *)deleteCoachWithCoachId:(NSString *)coachId
                                success:(void(^)(void))successBlock
                                failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-coach-api/admin/2.0.0/coachOutGym" parameters:@{@"coachId":SAFE_NIL_STRING(coachId)} criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        if (successBlock) {
            successBlock();
        }
        
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}
@end
